package com.acwing.partition13;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/2/28 15:23
 */
public class AC1238日志统计 {

    private static final int N = 100010;
    private static int[][] pairs = new int[N][2];
    private static int[] cnt = new int[N];
    private static boolean[] st = new boolean[N];
    private static int n, d, k;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        d = Integer.parseInt(ss[1]);
        k = Integer.parseInt(ss[2]);
        for (int i = 0; i < n; i++) {
            ss = reader.readLine().split(" ");
            int ts = Integer.parseInt(ss[0]), id = Integer.parseInt(ss[1]);
            pairs[i] = new int[]{ts, id};
        }
        Arrays.sort(pairs, 0, n, (o1, o2) -> Integer.compare(o1[0], o2[0]));
        for (int i = 0, j = 0; i < n; i++) {
            int id = pairs[i][1];
            cnt[id]++;
            while (pairs[i][0] - pairs[j][0] >= d) cnt[pairs[j++][1]]--;
            if (cnt[id] >= k) st[id] = true;
        }
        for (int i = 0; i < N; i++) {
            if (st[i]) writer.write(i + "\n");
        }
        writer.flush();
    }
}
